using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication11.Models.Mapping
{
    public class online_survey_lineMap : EntityTypeConfiguration<online_survey_line>
    {
        public online_survey_lineMap()
        {
            // Primary Key
            this.HasKey(t => new { t.status, t.online_survey_id, t.survey_question_sheet_id, t.relative_order });

            // Properties
            this.Property(t => t.status)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.comments)
                .HasMaxLength(20);

            this.Property(t => t.online_survey_id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.survey_question_sheet_id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.relative_order)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            // Table & Column Mappings
            this.ToTable("online_survey_line");
            this.Property(t => t.status).HasColumnName("status");
            this.Property(t => t.comments).HasColumnName("comments");
            this.Property(t => t.online_survey_id).HasColumnName("online_survey_id");
            this.Property(t => t.survey_question_sheet_id).HasColumnName("survey_question_sheet_id");
            this.Property(t => t.relative_order).HasColumnName("relative_order");

            // Relationships
            this.HasRequired(t => t.online_survey)
                .WithMany(t => t.online_survey_line)
                .HasForeignKey(d => d.online_survey_id);
            this.HasRequired(t => t.online_survey_question_sheet)
                .WithMany(t => t.online_survey_line)
                .HasForeignKey(d => d.survey_question_sheet_id);

        }
    }
}
